//
//  PostSheetView.m
//  GoldBook
//
//  Created by wmz on 2021/8/19.
//  Copyright © 2021 wmz. All rights reserved.
//

#import "PostSheetView.h"
@interface PostSheetView()

@end
@implementation PostSheetView
- (void)hd_setupViews{
    @HDWeakify(self)
    self.frame = CGRectMake(0, 0, PostWidth, PostHeight);
    self.shadomView = Add_View(^(UIView * _Nonnull view) {
        view.backgroundColor = wColor_3;
        view.alpha = 0.3;
        view
        .add_event(^(UIView * _Nonnull sender) {
            @HDStrongify(self)
            [self dissmiss];
        })
        .add_constraints(^(MASConstraintMaker * _Nullable make) {
            make.edges.mas_equalTo(0);
        }, self);
    });
}


- (void)show{
    [self.superview endEditing:YES];
    self.open = YES;
    [self layoutIfNeeded];
    CGRect rect = self.contenView.frame;
    self.shadomView.alpha = 0;
    self.contenView.frame = CGRectMake(rect.origin.x, [UIScreen mainScreen].bounds.size.height , rect.size.width, rect.size.height);
    [UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
        self.shadomView.alpha = 0.3;
        self.contenView.frame = rect;
    } completion:^(BOOL finished) {

    }];
}

- (void)dissmiss{
    [self dissmiss:YES];
}

- (void)dissmiss:(BOOL)animal{
    self.open = NO;
    if (animal) {
        CGRect rect = self.contenView.frame;
        [UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
            self.shadomView.alpha = 0;
            self.contenView.frame = CGRectMake(rect.origin.x, [UIScreen mainScreen].bounds.size.height , rect.size.width, rect.size.height);
        } completion:^(BOOL finished) {
            [self removeFromSuperview];
        }];
    }else{
        [self removeFromSuperview];
    }
}


@end
